package com.example.demo.use_demo.a_springboot_start;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author farben
 */
@Slf4j
@Configuration
public class DemoConfig {

    /**
     * '@Bean'用于将Bean存入SpringIOC容器
     */
    @Bean
    public DemoInitializingBean demoInitializingBean(){
        log.info(">>>>>>>>>>>>>>>>>>>>>> demo initialize bean >>>>>>>>>>>>>>>>>>>>>");
        return new DemoInitializingBean();
    }

    /**
     * '@Bean(initMethod="initDemoBeanMethod")'在这个例子中，
     *  DemoBean的实例会被创建，并且作为名为demoBean的bean注册到Spring容器中，
     *  在DemoBean被实例化时，会自动调用DemoBean的initDemoBeanMethod方法
     */
    @Bean(initMethod = "initDemoBeanMethod")
    public DemoBean demoBean(){
        log.info(">>>>>>>>>>>>>>>>>>>>>> demo bean >>>>>>>>>>>>>>>>>>>>>");
        return new DemoBean();
    }

}
